
#include "server.hpp"
#include <string>

#define HOST "127.0.0.1"
#define PORT 3306
#define USER "root"
#define PASS "Hsyq@20250801"
#define DBNAME "xg_gobang"
void db_test()
{
    user_table ut(HOST, USER, PASS, DBNAME, PORT);
    Json::Value usr;
    usr["username"] = "111";
    // usr["password"] = "20250810";
    ut.insert(usr);
    // bool ret=ut.login(usr);
    // std::cout<<ret<<std::endl;
    // Json::Value usr1;
    // ut.select_by_name("北京",usr1);
    // std::cout<<"username: "<<usr1["username"].asCString()<<"\t"
    //             <<"score: "<<usr1["score"].asUInt64()<<"\t"
    //             <<"total_count: "<<usr1["total_count"].asInt()<<"\t"
    //             <<"win_count: "<<usr1["win_count"].asInt()<<std::endl;
    // Json::Value usr2;
    // ut.select_by_id(1, usr2);
    // std::cout << "username: " << usr2["username"].asCString() << "\t"
    //           << "score: " << usr2["score"].asUInt64() << "\t"
    //           << "total_count: " << usr2["total_count"].asInt() << "\t"
    //           << "win_count: " << usr2["win_count"].asInt() << std::endl;
    // ut.win(1);
    // Json::Value usr2;
    // ut.select_by_id(1, usr2);
    // std::cout << "username: " << usr2["username"].asCString() << "\t"
    //           << "score: " << usr2["score"].asUInt64() << "\t"
    //           << "total_count: " << usr2["total_count"].asInt() << "\t"
    //           << "win_count: " << usr2["win_count"].asInt() << std::endl;
    // std::cout<<"################"<<std::endl;
    // ut.lose(1);
    // Json::Value usr3;
    // ut.select_by_id(1, usr3);
    // std::cout << "username: " << usr3["username"].asCString() << "\t"
    //           << "score: " << usr3["score"].asUInt64() << "\t"
    //           << "total_count: " << usr3["total_count"].asInt() << "\t"
    //           << "win_count: " << usr3["win_count"].asInt() << std::endl;
}
void test_room()
{
    online_user online;
    user_table us_tb(HOST,USER,PASS,DBNAME,PORT);
    room r(1,&us_tb,&online);
    r.add_black_user(3);
    r.add_white_user(4);
}
void test_roomManager()
{
    online_user online;
    user_table us_tb(HOST,USER,PASS,DBNAME,PORT);

    roomManager rm(&online,&us_tb);
    room::ptr rp=rm.createRoom(1,2);
}


int main(int argc,char* argv[])
{
    // test_roomManager();
    // if(argc!=2)
    // {
    //     std::cout<<"Usge: ./gobang port"<<std::endl;
    //     return -1;
    // }
    // int port=std::stoi(argv[1]);
    // std::stoi(row[2]);
    gobang_server server(HOST,USER,PASS,DBNAME,PORT);
    server.start(8085);
    return 0;
}